package homework.server.terminal.impl;

import homework.server.terminal.Command;
import homework.server.terminal.Terminal;

public class QuitCommand implements Command {

    private String msg;

    public QuitCommand() {
        this(null);
    }

    public QuitCommand(String msg) {
        this.msg = msg;
    }

    @Override
    public int execute(String[] args, Terminal terminal) throws Exception {
        if(msg != null)
            terminal.sendMessage(msg);

        terminal.close();
        return 0;
    }
}
